package com.xuanwoa.rabbit.common;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Description
 *
 * @author: caomin
 * @since: 2020/11/23
 */
@Component
public class AbstractQueueLIstener implements ChannelAwareMessageListener {

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        System.out.println(JSON.toJSONString(message));
        System.out.println(JSON.toJSONString(channel));
    }

    @Override
    public void onMessage(Message message) {
        System.out.println(JSON.toJSONString(message));
    }

    @Override
    public void onMessageBatch(List<Message> messages, Channel channel) {
        System.out.println(JSON.toJSONString(messages));
        System.out.println(JSON.toJSONString(channel));
    }
}
